package com.baby.core.page1;

import com.baby.core.page2.Dialect;

public class OracleDialect extends Dialect {

	@Override
	public String getLimitString(String sql, int offset, int limit) {

		sql = sql.trim();
		StringBuffer pagingSelect = new StringBuffer(sql.length() + 100);

		pagingSelect.append("SELECT * FROM ( SELECT a.*, ROWNUM rownum_ FROM ( ");

		pagingSelect.append(sql);

		pagingSelect.append(" ) a WHERE ROWNUM <= ").append(limit).append(") WHERE rownum_ >= ")
				.append(offset);

		return pagingSelect.toString();
	}
}
